#include <stdio.h>
float F1(float x)
{
    float y;
    y=1.0+x*x;
    return y;
}
float F2(float x)
{
    float y;
    y=x/(1.0+x*x);
    return y;
}
float Integral(float (*f)(float),float a,float b)
{
    float x[1000];
    float gap;
    float area=0;
    gap=(b-a)/1000.0;
    x[0]=a+0.5*gap;
    int i,k;
    for(k=1;k<1000;k++)
    {
        x[k]=x[k-1]+gap;
    }
    for(i=0;i<1000;i++)
    {
        area+=gap*((*f)(x[i]));
    }
    return area;
}
void main()
{
    printf("below are results of two kinds of integral\n");
    printf("y1=%f\n",Integral(F1,0,1));
    printf("y2=%f",Integral(F2,0,3));
}
